package org.windey.client;

import java.io.File;

import javax.swing.JOptionPane;

/**
 * 
 * mainklasse om windeyclient op te starten
 *
 */
public class WindeyClient
{
	/**
	 * main methode
	 * we maken indien er nog geen is een lokale map aan waarin we bestanden kunnen opslagen
	 * @param args
	 */
	public static void main(String[] args)
	{
		try
		{
			String dirname ="Windey Desktop Control";
			(new File(System.getProperty("user.home"), dirname)).mkdir();
		}
		catch (Exception e)
		{
			System.err.println("Error: " + e.getMessage());
		}
		new WindeyClient().test();
	}
	
	/**
	 * om te zien of de applicatie al openstaat of niet
	 * indien ja: melding
	 * indien nee: open programma
	 */
	private void test()
	{
        ControleerBestaan cb = new ControleerBestaan("windey_client_running");

        if (cb.isAppActive())
        {
        	JOptionPane.showMessageDialog(null,"Windey Client already running","Windey Client error",JOptionPane.WARNING_MESSAGE);
            System.exit(1);    
        }
        else
        {
        	File xmlFile = new File(System.getProperty("user.home")+"/Windey Desktop Control", "windey_client_settings.xml");
        	ClientGUI gui = new ClientGUI(new WindeyXmlSettings(xmlFile));
        	gui.show();
        }
	}
}
